package justdoit.view;

import javax.swing.JLabel;
import justdoit.Startup;
import justdoit.controller.TaskManager;
import justdoit.model.Task;
import justdoit.controller.LanguageManager;

/**
 *
 * @author shadone
 * this class will be for putting the task data onto the left panel
 * the idea is that when the user clicks on the task, the task details will be shown in the left panel
 */
public class LeftPanelDialog extends TaskDialog {

    private Task task;
    public JLabel taskLabel;
    public String taskDescription;
    public String taskCategory;
    public String taskPriority;
    public String taskDate;
    public int taskProgress;

    public LeftPanelDialog(Task task) {
        super(LanguageManager.getString("title.editTask"));
        updateInterfacebyTask(task);
        this.task = task;
        taskDescription = this.task.getDescription();
        taskCategory = this.task.getCategory();
        taskPriority = this.task.getPriority();
        taskDate = this.task.getDeadLine();
        taskProgress = this.task.getProgress();
    }

    public TaskDialog getInfoPanel() {
        return this;
    }

    public String getProgress() {
        return String.valueOf(taskProgress);
    }

    public String getDate() {
        return taskDate;
    }

    public String getPriority() {
        return taskPriority;
    }

    public String getDescription() {
        return taskDescription;
    }

    public String getCategory() {
        return taskCategory;
    }
    
    @Override
    protected void okAction() {
        getTaskFromInterface(this.task);
        if (TaskManager.updateTask(task) == -1) {
            System.out.println("Update failed!");
        } else {
            Startup.getMainFrame().getTaskListPanel().refreshData();
        }
        super.okAction();
    }
}
